Created: 02-10-2016
By: Giânck Luiz
Email: obviosistemas@gmail.com
Thank you for purchasing my project php. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here. Thanks so much!
Function designed to better security in corephp projects , SQL injection , XSS , CSRF
function anti_injection($sql){
$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"), "" ,$sql);
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = (get_magic_quotes_gpc()) ? $sql : addslashes($sql);
return $sql;
}
if (isset($_GET['filename']) {
$filename = $_GET['filename'];
header('Content-Type: application/x-octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $filename . '";');
echo file_get_contents($filename);
}
APPLICATION ENVIRONMENT
You can load different configurations depending on your
current environment. Setting the environment also influences
things like logging and error reporting.
This can be set to anything, but default usage is:
development
testing
production
NOTE: If you change these, also change the error_reporting() code below
Edit File - adm/config/conexao.php
define('ENVIRONMENT', ''); development or production
http://yourdomain.com/install.php
Please make sure you don't have $ sign in your password.
We will provide the service to install the item for $10 To request the installation, please send $10 to gianckluiz@hotmail.com by Paypal and email us your license file and hosting control panel details with reference of your payment to obviosistemas@gmail.com
As you know developed the WHMX in CorePHP ie there are not many secrets you can deploy new features , classes and functions normally in each module you want.
There is a class to support the templates I created this to her side where you can see your code and understand its operation.
Please Backup EVER!
Use require_once to include the Template class and use the policy to inform the namespace of the class, as follows:
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
Example and explanation : Hello World
The basic operation of the template mechanism is based on the following idea : you have a PHP file (which will use the library ) , and this file does not contain any HTML code. The HTML code will be separated in a file that will contain only HTML code . This HTML file is read by the PHP file. By the way , everything will be processed in the PHP file.
That said, we go to the first example, the already jaded Hello world. We will create two files: PHP responsible for all logic , and the HTML file with our layout.
Then , create an HTML file called hello.html with the content below:
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
$tpl = new MVC("hello.html");
$tpl->show();
Let's now an important concept : template variables . As you can imagine , you want to change various parts of the HTML file. How to do this? Simple: on the side of HTML , you create so-called template variables . See the example below :
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
$tpl = new MVC("hello.html");
$tpl->NAME_USER = "JEAN";
$tpl->show();
< s p a n >{NAME_USER}< / s p a n >
If you want to assign value to a template variable, but are not sure if the variable exists, you can use the exists () method to make this check.
As you might expect, it returns true if the variable exists. If not , it returns false :
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
$tpl = new MVC("layout.html");
if($tpl->exists("NAME_USER")) $tpl->NAME_USER = "JEAN";
$tpl->show();
Note that the start and end of the block are identified by an HTML comment with the word BEGIN (to identify early ) or END (to identify end) and the block name then.
The words BEGIN and END must always be capitalized. The block name must contain only letters , numbers or underscore.
And then in the PHP side we checked whether products exist. If so, we show the BLOCK_QUANTIDADE block. If not, we'll display the BLOCK_VAZIO block.
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
$tpl = new MVC("hello.html");
$qtd = 5;
if($qtd > 0){
$tpl->QUANT = $qtd;
$tpl->block("BLOCK_USERS");
}
else {
$tpl->block("BLOCK_NOT_USERS");
}
$tpl->show();
< !-- BEGIN BLOCK_USERS -->
There {QUANT} users.
< !-- END BLOCK_USERS -->
< !-- BEGIN BLOCK_NOT_USERS -->
There is no registered user.
< !-- END BLOCK_NOT_USERS -->
Using multiple HTML files
A common use of templates is to use an HTML file that contains the basic structure of our website: header, footer , menus , etc. And another file with the content of the page we want to show , that is, the " core" . Thus , we need not repeat all HTML files in the common elements ( header, footer , etc. ) , and HTML pages that have content (the " core" ) will be cleaner , smaller and easier to maintain.
How to do this with templates? First, let's create our file "base" HTML, base.html file:
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
$tpl = new MVC("base.html");
$tpl->addFile("HEADER", "header.html");
$tpl->NAME = "JEAN";
$products = array(
array("product" => "Sabão em Pó", "qtd" => 15),
array("product" => "Escova de Dente", "qtd" => 53),
array("product" => "Creme Dental", "qtd" => 37)
);
foreach($products as $p){
$tpl->PRODUCT = $p["product"];
$tpl->QTD = $p["qtd"];
$tpl->block("BLOCK_PRODUCTS");
}
$tpl->show();
Storing the template content.
So far we display the template -generated content on the screen through the show () method. But what we want to do another use for that content , how to save it in another file or something? Just we use the parse () method, which generates the final content and returns :
require_once("adm/config/mega.class.php");
use megaphp\view\MVC;
$tpl = new MVC("base.html");
$tpl->addFile("HEADER", "header.html");
$tpl->NAME = "JEAN";
$content = $tpl->parse();
// Save
file_put_contents("file.txt", $content);
The Template class supports the allocation of objects to template variables from version 1.5 (check the source code version of your class).
This helps a lot if we are using some ORM library, as Doctrine2 , the ORM Kohana or Eloquent the Laravel.
This makes the code in PHP files be greatly reduced (of course, provided you use objects) , and because of this, there is an improvement ( barely perceptible ) performance.
For the examples become more clear, we will work with an alleged page that displays details of a product. Products have as attributes : id and name.
The Template class work both with classes that use encapsulation ( get and set the attribute) , and for classes that call the attributes directly (usually through the magical PHP methods) .
// src/Product.php
class Product
{
/**
* @var int
*/
protected $id;
/**
* @var string
*/
protected $name;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
Guide to add new language.
en.php
To call the language create a link or select action to call via GET the code language example :
index.php?lang=en
Thanks to all the friends for their suggestions, feedback and help.
Once again, thank you so much for purchasing this project php. As I said at the beginning, I'd be glad to help you if you have any questions relating to this theme. No guarantees, but I'll do my best to assist. If you have a more general question relating to codecanyon, you might consider visiting the forums and asking your question in the "Item Discussion" section.
Giânck Luiz - ObvioSistemas